Skip to content

Handle call_ref in asyncify pass#8329

Open
sumleo wants to merge 1 commit intoWebAssembly:mainfrom
sumleo:fix-asyncify-call-ref
Open

Handle call_ref in asyncify pass#8329
sumleo wants to merge 1 commit intoWebAssembly:mainfrom
sumleo:fix-asyncify-call-ref

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 16, 2026

Summary

  • The asyncify pass handles Call and CallIndirect but not CallRef in three critical locations:
    1. ModuleAnalyzer Walker: Only visitCall and visitCallIndirect are handled; call_ref instructions don't propagate canChangeState.
    2. canChangeState() Walker: CallRef is not visited, so call_ref is treated as non-state-changing.
    3. doesCall(): Only checks for Call and CallIndirect, missing CallRef.
  • As a result, functions containing call_ref are not properly instrumented—the call_ref is wrapped with makeMaybeSkip instead of receiving full unwind/rewind support.
  • Note that AsyncifyUnwindWalker (for the unwind phase) already handles CallRef correctly, confirming this is an oversight in the other locations.
  • Added visitCallRef handlers in both walkers and included CallRef in doesCall(), treating it the same as CallIndirect.

Test plan

  • Added test/lit/passes/asyncify-call-ref.wast verifying that call_ref receives proper asyncify instrumentation (unwind block, call index tracking, state checks).
  • All existing unit tests pass.

The asyncify pass handles Call and CallIndirect but not CallRef. This
means call_ref instructions are not recognized as calls in ModuleAnalyzer,
canChangeState(), or doesCall(), so they are never properly instrumented
with asyncify's unwind/rewind support.

Add visitCallRef handlers alongside the existing visitCallIndirect
handlers in both walkers, and include CallRef in the doesCall() check.
CallRef is treated the same as CallIndirect since both are indirect calls
where the target may change state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant